package kg.aibek.projecteuler.p10;

public class Problem46 {
	public void solve() {
		for (int i = 35; i < Integer.MAX_VALUE; i += 2) {
			if (isPrime(i))
				continue;
			if (!isConjecture(i)) {
				System.out.println(i);
				break;
			}
		}
	}

	private boolean isConjecture(int number) {
		for (int i = 1; i * i < number; i++) {
			int rem = number - 2 * i * i;
			if (rem > 0 && isPrime(rem)) {
				return true;
			}
		}
		return false;
	}

	private boolean isPrime(int number) {
		if (number == 1) {
			return false;
		}

		for (int i = 2; i * i <= number; i++) {
			if (number % i == 0) {
				return false;
			}
		}
		return true;
	}

	public static void main(String[] args) {
		Problem46 p = new Problem46();
		p.solve();
	}
}
